<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>20的博客-后台登录</title>
	<%-- <%@ include file="/static/head.jsp"%> --%>
	<%@ include file="/WEB-INF/view/head.jsp"%>
</head>
<body  style="background-image: url('<c:url value="/static/blog/img/back.png"/>');">
	<div style="height: 300px;width: 400px;
		 border:1px solid #96c2f1;background:#eff7ff;
		position:absolute;
   		top:50%;left:50%;margin:-150px 0 0 -200px;
   		border-radius: 5px;padding: 15px;">
   		<!-- <div style="background-color: #aaa;border-radius: 5px;text-align: center;"><h2>登录</h2></div> -->
   		LOGIN...
   		<hr style="height:1px;border:none;border-top:1px solid #555555;" />
		账号：
		<input id="account" type="text" name="account" class="form-control" placeholder="请输入账号！" />
		密码：
		<input id="password" type="password" name="password" class="form-control" placeholder="请输入密码！"/>
		<br>
		<div>验证码：<input id="code" type="text" name="code" style="width: 60px;" /><span onclick="vimg(this)"><img alt="" src="<c:url value="/code/validate/123" />"></span></div>
		<div>
			<button onclick="login()">提交</button>
			<button onclick="back()">返回主页？</button> 
		</div>
	</div>
</body>
<script type="text/javascript">
function login(){
	$.ajax({
		   type:"POST",
		   url: '<c:url value='/login/backLoginValidate'/>',
		   data:{
			   account : $("#account").val(),
			   password : $("#password").val(),
			   code : $("#code").val()
		   },
		   dataType : "json",
		   async: false,
		   success:function(data){
			   if(data.code == '200'){
				   window.location.href = '<c:url value='/back/mainpage'/>';
			   }
		   },
		   error : function(e) {
			   alert("确认失败！");
			}
		  });
}

function back(){
	window.location.href = '<c:url value='/'/>';
}

function vimg(s){
	var url = '<c:url value="/code/validate/" />';
	url+= Date.parse(new Date()); 
	$(s).children().eq(0).attr("src",url);
}
</script>
</html>